﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace ESpace
{
    public partial class ETextBoxOneRow : UserControl
    {
        public ETextBoxOneRow()
        {
            InitializeComponent();
        }
        bool pExitByEsc = true;
        [DefaultValue(true)]
        public bool ExitByEsc
        {
            get { return pExitByEsc; }
            set { pExitByEsc = value; }
        }

        public override String Text
        {
            get { return txb.Text; }
            set { txb.Text = value; }
        }
       
        public void Exit()
        {
            Color clr = txb.BackColor;
            txb.Enabled = false;
            txb.BackColor = clr;
        }

        private void ETextBox_MouseDown(object sender, MouseEventArgs e)
        {
            txb.Enabled = true;
            txb.Focus();
        }

        private void txb_KeyDown(object sender, KeyEventArgs e)
        {
            if (ExitByEsc && e.KeyCode == Keys.Escape)
                Exit();
        }
    }
}
